/*
 *  Cell.h
 *  
 *
 *  Created by Daniel Condon on 25/07/12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */

#include <string>

using namespace std;

class Cell{
private:
	int px, py;
	int currentCreatures;
	int maxCreatures;
	int migrants;
	bool recieved;
	bool barriers[4];
	bool Spreadable;
public:
	//--Default constructor
	//--will pass zeros to secondary constructor
	Cell();
	
	/*--Secondary Constructor
	 will pass x and y values to final constructor and zeros as the popluation
	Params:
	 Parameter(0) : x coordinate of the cell
	 Parameter(1) : y coordinate of the cell
	Pre: Parameter(0&1) not outside the limits of the matrix	 
	 */
	Cell(int, int);
	
	/*--Terciary Constructor
	 Params:
	 Parameter(0) : x coordinate of the cell
	 Parameter(1) : y coordinate of the cell
	 Parameter(2) : current population of the cell
	 Parameter(3) : maximum population of the cell
	 Pre: Parameter(0&1) not outside the limits of the matrix	
		Parameter(2) not greater than Parameter(3)
	 */
	Cell(int, int, int);
	
	/*--Final Constructor
	 Params:
	 Parameter(0) : x coordinate of the cell
	 Parameter(1) : y coordinate of the cell
	 Parameter(2) : maximum population of the cell
	 Parameter(3) : terrain type of the cell
	 Pre: Parameter(0&1) not outside the limits of the matrix
	 Parameter(3) is a valid terrain type
	 */
	//Cell(int, int, int, string);
	
	void setCellPos(int, int);
	
	/*--will set  parameter 0 & 1 to the grid coordinates x & y respectively
	 Params:
	 Parameter(0) : int pointer, will be set to the cells X coordinate
	 Parameter(1) : int pointer, will be set to the cells Y coordinate
	*/
	void getCellPos(int*, int*);
	
	/*--will return the cells current population
	 Return : Cells current population
	 */
	double getCellCurrent();
	
	/*--will return the cells maximum population
	 Return : cells maximum population
	 */
	double getCellMax();
	
	/*--This function will return current percentage of maximum load
	 Pre : cell population and maximum both not NULL
	 Returns : % of cell max population
	 */
	double getCellPercent();
	
	/*--This function will return the number of migrants sent
	 Pre : number of migrants is not NULL or negative
	 Return : return number of migrants received during current tick
	 */
	int getMigrantNum();
	
	/*--This function will remove the migrants from this cell 
		in preperation for their move
	 Params:
	 Parameter(0) : number of migrants moving
	 Pre : number of migrants is not NULL or negative
	 */
	void sendMigrants(int);
	
	/*--This function will receive the migrants without adding them 
		to the total population
	 Params:
	 Parameter(0) : number of incoming migrants
	 Pre : number of migrants is not NULL or negative
	 */
	void receiveMigrants(int);
	
	/*--This function will add the migrants to the population
	 */
	void incorporateMigrants();
	
	/*--This function will receive the amount of growth made during current tick
	 */
	void applyGrowth(int growth);
	
	/*--This function will place a barrier at one of the sides
	 (East, North, West, South) 
	 Params:
	 Parameter(0) : Side to place the barrier
	 Pre : side input between 1 and 4 inclusive
	 */
	void PlaceBarrier(int side);
	
	/*--This function will remove a barrier at one of the sides
	 (East, North, West, South) 
	 Params:
	 Parameter(0) : Side to remove the barrier
	 Pre : side input between 1 and 4 inclusive
	 */
	void RemoveBarrier(int side);
	
	/*--This function will check if a barrier is on the given side
	 (East, North, West, South)
	 Params:
	 Parameter(0) : Side to check the barrier
	 Pre : side input between 1 and 4 inclusive
	 Return : wether the side has a barrier
	 */
	bool hasBarrier(int side);
	
	/*--This function will check if the cell can spread
	 Return : if cell has 4 barriers,  will return false
	 */
	bool canSpread();
};